package com.jiangli.mapper;

import com.github.pagehelper.Page;
import com.jiangli.annotation.AutoFill;
import com.jiangli.dto.DishPageQueryDTO;
import com.jiangli.entity.Dish;
import com.jiangli.entity.DishMetaData;
import com.jiangli.enumeration.OperationType;
import com.jiangli.vo.DishVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;

@Mapper
public interface DishMapper {


    List<Long> selectAllIds();

    List<DishVO> selectByIdsAndPage(List<Long> randomIds, Integer offset, Integer pageSize);
    // 查询所有菜品元数据（仅包含排序需要的字段）
    List<DishMetaData> selectAllMetadata();

    // 按ID列表查询菜品详情
    List<Dish> selectByIds(@Param("ids") List<Long> ids);

    // 查询菜品总条数
    Long selectTotalCount();

    @Select("select * from dish where id=#{dishId}")
    Dish getByDishId(Long dishId);
    //查询所有菜品
    List<Dish> selectAllAvailable();

    @Select("select id from dish where merchant_id=#{merchantId}")
    List<Long> selectDishIdsByMerchantId(Long merchantId);

    @AutoFill(OperationType.UPDATE)
    void update(Dish dish);
    @AutoFill(OperationType.INSERT)
    void addDish(Dish dish);

    void deleteDish(Long id);

    @Delete("delete from dish where merchant_id=#{merchantId}")
    void deleteDishBymerchantId(Long merchantId);
}
